<template>
  <div>
    <el-select v-model="value" placeholder="请选择" @change="setSelectRecord">
      <el-option
        v-for="item in options"
        :key="item"
        :label="item"
        :value="item"
      />
    </el-select>
  </div>
</template>

<script>
import { getToken } from '@/utils/auth'

const record = {
  recordList: {
    recordCount: []
  }
}

export default {
  name: 'RecordSelectPanel',
  data() {
    return {
      headers: {
        'Authorization': getToken()
      },
      value: '1',
      options: []
    }
  },
  created() {
    this.getRecord()
  },
  methods: {
    setSelectRecord() {
      this.$emit('changeRecord', this.value)
    },
    async getRecord() {
      var axios = require('axios')

      var config = {
        method: 'get',
        url: 'http://localhost:8013/api/fdsData/record/list',
        headers: {
          'Authorization': this.headers.Authorization
        }
      }

      await axios(config)
        .then(function(response) {
          record.recordList.recordCount = response.data.data
        })
        .catch(function(error) {
          console.log(error)
        })
      this.options = record.recordList.recordCount
    }
  }
}
</script>

<style scoped>

</style>

